class Solution {
    public int search(int[] nums, int target) {
        int left = 0;
        int rigth = nums.length - 1;
        while(left<=rigth) {
            if(nums[left]==target) return left;
            if(nums[rigth]==target) return rigth;
            left++;
            rigth--;
        }
        return -1;
    }
}